<?php
include("../connection.php");
include("heder1.php");
//echo  $ceraterid=$_SESSION['userid'];

?>
<link rel="stylesheet" type="text/css" media="all" href="jsDatePick_ltr.min.css" />
<script type="text/javascript" src="jsDatePick.min.1.3.js"></script>
<script type="text/javascript">
	window.onload = function(){
		new JsDatePick({
			useMode:2,
			target:"inputField",
			dateFormat:"%Y-%m-%d"
			
		});
	};
</script>



<?php

if($_GET['action']=="delete")
{
 $id=$_GET['id'];
 mysql_query("DELETE FROM event WHERE id='".$id."'")or die(mysql_error());
 echo"deleted";
}

if($_GET['action']=="edit")
{
 $id=$_GET['id'];
 
 $q=mysql_query("SELECT * FROM event WHERE id='".$id."'")or die(			    mysql_error());
 
 $row = mysql_fetch_array($q);
 
  	  $eventname=$row["eventname"];
	  $venue=$row["venue"];
	  $date=$row["date"];
	  $starttime=$row["starttime"];
	  $endtime=$row["endtime"];
	  $maixumnumber=$row["maxnum"];
	  $guest=$row["guest"];
	  $des=$row["des"];
	  $payment=$row["payment"];
	  $type=$row["type"];
 
    $time1=$row['time1'];
    $time2=$row['time2'];
	$time3=$row['time3'];
	$time4=$row['time4'];
	$time5=$row['time5'];
	$time6=$row['time6'];
	$time7=$row['time7'];
	$time8=$row['time8'];
	$time9=$row['time9'];
	$time10=$row['time10'];
	
	  $program1=$row['program1'];
	  $program2=$row['program2'];
	  $program3=$row['program3'];
	  $program4=$row['program4'];
	  $program5=$row['program5'];
	  $program6=$row['program6'];
      $program7=$row['program7'];
	  $program8=$row['program8'];
	  $program9=$row['program9'];
	  $program10=$row['program10'];
?>
<form name="form1" method="post" action="editevent.php?action=update&id=<?php echo  $_GET['id']; ?>">
<table width="299" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFD8B0">
  <tr>
    <td colspan="2"><div align="center"><h2>EDIT THE EVENT</h2> </div></td>
  </tr>
  <tr>
    <td width="150"><h4>Event name</h4> </td>
    <td width="143">
      
   
     <input type="text" name="eventname" value="<?php echo $eventname; ?>"></td>
  </tr>
  <tr>
    <td><h4>Vanue</h4></td>
    <td>
      <input type="text" name="venue" value="<?php echo   $venue; ?>" >
    </td>
  </tr>
  <tr>
    <td><h4>Date</h4></td>
    <td><input type="text" name="date" value="<?php echo   $date; ?>" id="inputField"></td>
  </tr>
  <tr>
    <td><h4>Steart time</h4></td>
    <td><input type="text" name="starttime" value="<?php echo   $starttime; ?>"></td>
  </tr>
  <tr>
    <td><h4>End time</h4> </td>
    <td>
      <input type="text" name="endtime" value="<?php echo   $endtime; ?>">
    </td>
  </tr>
  <tr>
    <td><h4>Maximum number</h4></td>
    <td><input type="text" name="maximumnumber" value="<?php echo  $maixumnumber; ?>"></td>
  </tr>
  <tr>
    <td><h4>guest</h4></td>
    <td><input type="text" name="guest" value="<?php echo   $guest; ?>"></td>
  </tr>
  <tr>
    <td><h4>Discribution</h4></td>
    <td><input type="text" name="des" value="<?php echo   $des; ?>"></td>
  </tr>
  <tr>
    <td><h4>Payment</h4></td>
    <td><input type="text" name="payment" value="<?php echo   $payment; ?>"></td>
  </tr>
   <tr>
    <td><h4>Event type</h4></td>
    <td>
	<select name="type" >
	<option value='<?php echo  $type; ?>'><?php echo   $type; ?></option>
	<?php
	$result=mysql_query("SELECT * FROM eventtype");
	while($row=mysql_fetch_array($result))
	{
	echo"<option value='".$row['title']."'>".$row['title']."</option>";
	}
	?>
	</select>	</td>
  </tr>
  <tr>
  
  <td colspan="2"><h4 align="center">Edit the aganda</h4></td>
    </tr>
  <tr>
    <td><h4 align="center">Time interval</h4></td>
    <td><h4 align="center">Program list</h4></td>
  </tr>
  
  <tr>
    <td><input type="text" name="time1" value="<?php echo   $time1; ?>"></td>
    <td><input type="text" name="program1" value="<?php echo   $program1; ?>"></td>
  </tr>
  <tr>
    <td><input type="text" name="time2" value="<?php echo   $time2; ?>"></td>
    <td><input type="text" name="program2" value="<?php echo   $program2; ?>"></td>
  </tr>
  <tr>
    <td><input type="text" name="time3" value="<?php echo   $time3; ?>"></td>
    <td><input type="text" name="program3" value="<?php echo   $program3; ?>"></td>
  </tr>
  <tr>
    <td><input type="text" name="time4" value="<?php echo   $time4; ?>"></td>
    <td><input type="text" name="program4" value="<?php echo   $program4; ?>"></td>
  </tr>
  <tr>
    <td><input type="text" name="time5" value="<?php echo   $time5; ?>"></td>
    <td><input type="text" name="program5" value="<?php echo   $program5; ?>"></td>
  </tr>
  <tr>
    <td><input type="text" name="time6" value="<?php echo   $time6; ?>"></td>
    <td><input type="text" name="program6" value="<?php echo   $program6; ?>"></td>
  </tr>
  <tr>
    <td><input type="text" name="time7" value="<?php echo   $time7; ?>"></td>
    <td><input type="text" name="program7" value="<?php echo   $program7; ?>"></td>
  </tr>
  <tr>
    <td><input type="text" name="time8" value="<?php echo   $time8; ?>"></td>
    <td><input type="text" name="program8" value="<?php echo   $program8; ?>"></td>
  </tr>
  <tr>
    <td><input type="text" name="time9" value="<?php echo   $time9; ?>"></td>
    <td><input type="text" name="program9" value="<?php echo   $program9; ?>"></td>
  </tr>
  <tr>
    <td><input type="text" name="time10" value="<?php echo   $time10; ?>"></td>
    <td><input type="text" name="program10" value="<?php echo   $program10; ?>"></td>
  </tr>
  <tr>
    <td colspan="2"><label>
      <div align="center">
        <input type="submit" name="Submit2" value="update" />
      </div>
    </label></td>
  </tr>
</table>
</form>



<?php
} else{
?>


<?php
}
if($_GET["action"]=="update")
{
	 $id=$_GET['id'];
	  $eventname=$_POST["eventname"];
	  $venue=$_POST["venue"];
	  $date=$_POST["date"];
	  $starttime=$_POST["starttime"];
	  $endtime=$_POST["endtime"];
	  $maixumnumber=$_POST["maximumnumber"];
	  $guest=$_POST["guest"];
	  $des=$_POST["des"];
	  $payment=$_POST["payment"];
	  $type=$_POST["type"];
	  
	$time1=$_POST["time1"];
	$time2=$_POST["time2"];
	$time3=$_POST["time3"];
	$time4=$_POST["time4"];
	$time5=$_POST["time5"];
	$time6=$_POST["time6"];
	$time7=$_POST["time7"];
	$time8=$_POST["time8"];
	$time9=$_POST["time9"];
	$time10=$_POST["time10"];
	
	 $program1=$_POST["program1"];
     $program2=$_POST["program2"];
	 $program3=$_POST["program3"];
	 $program4=$_POST["program4"];
	 $program5=$_POST["program5"];
	 $program6=$_POST["program6"];
	 $program7=$_POST["program7"];
	 $program8=$_POST["program8"];
	 $program9=$_POST["program9"];
	 $program10=$_POST["program10"];
	  


 mysql_query("UPDATE event SET 
  			     eventname='".$eventname."',venue='".$venue."',date='".$date."',
				 starttime='".$starttime."',endtime='".$endtime."',maxnum='".$maixumnumber."',
				 guest='".$guest."',des='".$guest."',payment='".$payment."',
				 type='".$type."',time1='".$time1."',time2='".$time2."',time3='".$time3."',time4='".$time4."',time5='".$time5."',time6='".$time6."',time7='".$time7."',time8='".$time8."',time9='".$time9."',time10='".$time10."',program1 ='".$program1."',program2 ='".$program2."',program3 ='".$program3."',program4 ='".$program4."',program5 ='".$program5."',program6 ='".$program6."',program7 ='".$program7."',program8 ='".$program8."',program9 ='".$program9."',program10 ='".$program10."' WHERE id='".$id."' ")or die(mysql_error());





} 
	$result=mysql_query("SELECT * FROM event WHERE ceraterid='".$_SESSION['userid']."'");
	$total = mysql_num_rows($result);
	$i=0;
	 echo'<table width="600" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td>eventname</td>
    <td>vanue</td>
    <td>date</td>
    <td>starttime</td>
    <td>endtime</td>
    <td>guest</td>
    <td>type</td>
    <td>deleat</td>
    <td>edit</td>
  </tr>';


	while($i< $total)
	{
	$row=mysql_fetch_array($result);
	
	  $eventname = $row['eventname'];
	  $venue=$row["venue"];
	  $date=$row["date"];
	  $starttime=$row["starttime"];
	  $endtime=$row["endtime"];
	  $maixumnumber=$row["maxnum"];
	  $guest=$row["guest"];
	  $des=$row["des"];
	  $payment=$row["payment"];
	  $type=$row["type"];
	
	//echo $eventname."<br>";
	//echo $vanue."<br>";
	//echo $date."<br>";
	echo"
	<tr>
	<td>".$eventname."</td>
	<td>".$venue."</td>
	<td>".$date."</td>
	<td>".$starttime."</td>
	<td>".$endtime."</td>

	<td>".$guest."</td>
	

	<td>".$type."</td>
	<td><a href='?action=delete&id=".$row["id"]."'><img src='delete.png' border='0'/><a/>   </td>
    <td><a href='?action=edit&id=".$row["id"]."'><img src='edit.png' border='0'/><a/>
	</td>
	
	</tr>";
	
	$i++;
	}
	echo "</table>";
	
	include("../footer.php");
	
	?>